started work on the tiff non-incremental loader.
authorJonathan Blandford <jrb@redhat.com>
Thu, 28 Oct 1999 14:46:46 +0000 (14:46 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Thu, 28 Oct 1999 14:46:46 +0000 (14:46 +0000)
1999-10-28  Jonathan Blandford  <jrb@redhat.com>

* src/io-tiff.c (image_load_increment): started work on the tiff
non-incremental loader.

* src/io-gif.c (image_load_increment): started work on the gif
incremental loader.

* src/gdk-pixbuf-io.h: Changed ModuleType to GdkPixbufModule.

gdk-pixbuf/ChangeLog
gdk-pixbuf/gdk-pixbuf-io.c
gdk-pixbuf/gdk-pixbuf-io.h
gdk-pixbuf/gdk-pixbuf-loader.c
gdk-pixbuf/io-gif.c
gdk-pixbuf/io-tiff.c
gtk/gdk-pixbuf-loader.c

index 37e3697a0a98fb5883fb545e8fc4ad1cbabfb2b3..7759d2565f9618bbe456d675c0cd2249862ca1ca 100644 (file)
@@ -1,3 +1,13 @@
+1999-10-28  Jonathan Blandford  <jrb@redhat.com>
+
+       * src/io-tiff.c (image_load_increment): started work on the tiff
+       non-incremental loader.
+
+       * src/io-gif.c (image_load_increment): started work on the gif
+       incremental loader.
+
+       * src/gdk-pixbuf-io.h: Changed ModuleType to GdkPixbufModule.
+
 1999-10-27  Federico Mena Quintero  <federico@redhat.com>
 
        * src/gdk-pixbuf-render.c (gdk_pixbuf_render_threshold_alpha): New
index bc00617b97f128f856c9b2bf3a6164ae3a5f634c..16c8049e5398abd06b89dfbd498bbd63dafba487 100644 (file)
@@ -135,7 +135,7 @@ pixbuf_check_ppm (guchar *buffer, int size)
 }
 #endif
 
-ModuleType file_formats [] = {
+GdkPixbufModule file_formats [] = {
        { "png",  pixbuf_check_png, NULL,  NULL, NULL, NULL, NULL, NULL },
        { "jpeg", pixbuf_check_jpeg, NULL, NULL, NULL, NULL, NULL, NULL },
        { "tiff", pixbuf_check_tiff, NULL, NULL, NULL, NULL, NULL, NULL },
@@ -150,7 +150,7 @@ ModuleType file_formats [] = {
 };
 
 static void
-image_handler_load (ModuleType *image_module)
+image_handler_load (GdkPixbufModule *image_module)
 {
        char *module_name;
        char *path;
@@ -205,7 +205,7 @@ image_handler_load (ModuleType *image_module)
 
 \f
 
-ModuleType *
+GdkPixbufModule *
 gdk_pixbuf_get_module (gchar *buffer, gint size)
 {
        gint i;
@@ -224,7 +224,7 @@ gdk_pixbuf_new_from_file (const char *filename)
        gint size;
        FILE *f;
        char buffer [128];
-       ModuleType *image_module;
+       GdkPixbufModule *image_module;
 
        f = fopen (filename, "r");
        if (!f)
index 74520398bc0bb7f04dd99a389f46bb85496e7c04..4486adfb66c672593e89c53b552227bd90be0c73 100644 (file)
@@ -30,8 +30,8 @@
 
 typedef void (* ModulePreparedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data);
 
-typedef struct _ModuleType ModuleType;
-struct _ModuleType {
+typedef struct _GdkPixbufModule GdkPixbufModule;
+struct _GdkPixbufModule {
        char *module_name;
        gboolean (* format_check) (guchar *buffer, int size);
        GModule *module;
@@ -45,5 +45,5 @@ struct _ModuleType {
 };
 
 
-ModuleType *gdk_pixbuf_get_module (gchar *buffer, gint size);
+GdkPixbufModule *gdk_pixbuf_get_module (gchar *buffer, gint size);
 
index c1fb1897fe06a4a0e53001fd3d417fcb45666e2e..c7c6c5cca60012c6a98471267140fc0ee66f102b 100644 (file)
@@ -53,7 +53,7 @@ typedef struct {
        gboolean closed;
        gchar buf[128];
        gint buf_offset;
-       ModuleType *image_module;
+       GdkPixbufModule *image_module;
        gpointer context;
 } GdkPixbufLoaderPrivate;
 
index 831c7ae440a467ed2a03a4b96d2a3fdb09a5d50f..38080c8e495cb8d71cb3ed9991315330dede1883 100644 (file)
@@ -27,7 +27,7 @@
 #include <glib.h>
 #include <gif_lib.h>
 #include "gdk-pixbuf.h"
-
+#include "gdk-pixbuf-io.h"
 \f
 
 /* Destroy notification function for the libart pixbuf */
@@ -44,10 +44,10 @@ image_load (FILE *f)
        gint fn, is_trans = FALSE;
        gint done = 0;
        gint t_color = -1;
-       gint w, h, i, j;
+       gint w = 0, h = 0, i, j;
        guchar *pixels, *tmpptr;
        GifFileType *gif;
-       GifRowType *rows;
+       GifRowType *rows = NULL;
        GifRecordType rec;
        ColorMapObject *cmap;
        int intoffset[] = { 0, 4, 2, 1 };
@@ -183,3 +183,71 @@ image_load (FILE *f)
                                         w, h, is_trans ? (w * 4) : (w * 3),
                                         free_buffer, NULL);
 }
+
+
+/* Progressive loader */
+typedef struct _GifData GifData;
+struct _GifData
+{
+       ModulePreparedNotifyFunc *func;
+       gpointer user_data;
+
+       GifFileType *gif_handle;
+       guchar *buf;
+       guint ptr;
+       gint size;
+};
+
+gpointer
+image_begin_load (ModulePreparedNotifyFunc *func, gpointer user_data)
+{
+       GifData *context;
+
+       context = g_new (GifData, 1);
+       context->func = func;
+       context->user_data = user_data;
+       context->buf = NULL;
+       context->gif_handle = NULL;
+       return context;
+}
+
+int
+myInputFunc (GifFileType *type, GifByteType *byte, int length)
+{
+       GifData *context;
+
+       context = (GifData *) type->UserData;
+       g_print ("in myInputFunc\nSize requested is %d\n", length);
+
+       if (length > context->size - context->ptr) {
+               memcpy (byte, context->buf + context->ptr, context->size - context->ptr);
+               return context->size - context->ptr;
+       }
+
+       memcpy (byte, context->buf + context->ptr, length);
+       return length;
+}
+
+void
+image_stop_load (gpointer context)
+{
+       g_free ((GifData *) context);
+}
+
+gboolean
+image_load_increment (gpointer data, guchar *buf, guint size)
+{
+       GifData *context = (GifData *) data;
+
+       g_print ("in load_increment: %d\n", size);
+       context->buf = g_realloc (context->buf, size);
+       context->ptr = 0;
+       context->size = size;
+       memcpy (context->buf, buf, size);
+
+       if ((context->gif_handle == NULL) && (context->size > 20))
+               context->gif_handle = DGifOpen (context, myInputFunc);
+
+       g_print ("width = %d, height = %d\n", context->gif_handle->SWidth, context->gif_handle->SHeight);
+       return FALSE;
+}
index d93dd1e5090bfd65469b84cdd63d0932e916c52a..b21dad4aeca81230aa5f87bfb74de721761cf3ae 100644 (file)
 /* Following code (almost) blatantly ripped from Imlib */
 
 #include <config.h>
-#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <tiffio.h>
 #include "gdk-pixbuf.h"
+#include "gdk-pixbuf-io.h"
 
 \f
 
@@ -99,3 +101,60 @@ image_load (FILE *f)
                                         w, h, w * 4,
                                         free_buffer, NULL);
 }
+
+/* Progressive loader */
+
+/*
+ * Tiff loading progressively cannot be done.  We write it to a file, then load
+ * the file when it's done.  
+ */
+
+typedef struct _TiffData TiffData;
+struct _TiffData
+{
+       ModulePreparedNotifyFunc *func;
+       gpointer user_data;
+
+       FILE *file;
+};
+
+gpointer
+image_begin_load (ModulePreparedNotifyFunc *func, gpointer user_data)
+{
+       TiffData *context;
+       gint fd;
+       char template[21];
+       
+       context = g_new (TiffData, 1);
+       context->func = func;
+       context->user_data = user_data;
+
+       strncpy (template, "/tmp/temp-tiffXXXXXX", strlen ("/tmp/temp-tiffXXXXXX"));
+       fd = mkstemp (template);
+       g_print ("fd=%d\n", fd);
+       context->file = fdopen (fd, "w");
+       if (context->file == NULL)
+               g_print ("it's null\n");
+       else
+               g_print ("it's not null\n");
+       return context;
+}
+
+void
+image_stop_load (gpointer data)
+{
+       TiffData *context = (TiffData*) data;
+       fclose (context->file);
+/*     unlink (context->file);*/
+       g_free ((TiffData *) context);
+}
+
+gboolean
+image_load_increment (gpointer data, guchar *buf, guint size)
+{
+       TiffData *context = (TiffData *) data;
+
+       g_assert (context->file != NULL);
+       fwrite (buf, sizeof (guchar), size, context->file);
+       return TRUE;
+}
index c1fb1897fe06a4a0e53001fd3d417fcb45666e2e..c7c6c5cca60012c6a98471267140fc0ee66f102b 100644 (file)
@@ -53,7 +53,7 @@ typedef struct {
        gboolean closed;
        gchar buf[128];
        gint buf_offset;
-       ModuleType *image_module;
+       GdkPixbufModule *image_module;
        gpointer context;
 } GdkPixbufLoaderPrivate;